home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / CPP100.ZIP / CPPFIC2A.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-22  |  7.7 KB  |  200 lines

  1. /*****************************************************************************/
  2. /*       (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved         */
  3. /*****************************************************************************/
  4. /*    This source-code is NOT public domain nor Freeware, this is part of    */
  5. /*              'The C Programming Package' which is Shareware.              */
  6. /*   If you use this code, please register and get a free Full-VGA version   */
  7. /*****************************************************************************/
  8.                             /*--------------------*
  9.                              *      CPPFIC2A.C    *
  10.                              *     FILE MANAGER   *
  11.                              *   other functions. *
  12.                              *   second part 1/2  *
  13.                              *--------------------*/
  14.  
  15.  /* Included Files */
  16.  # include <stdio.h>
  17.  # include <io.h>
  18.  # include <dos.h>
  19.  # include <fcntl.h>
  20.  # include <bios.h>
  21.  # include <stdlib.h>
  22.  # include <conio.h>
  23.  # include <dir.h>
  24.  # include <string.h>
  25.  # include <alloc.h>
  26.  # include <mem.h>
  27.  # include <process.h>
  28.  # include <conio.h>
  29.  
  30.  /* Global Variables */
  31.  extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,menu1,return1;
  32.  extern int colour1,colour2,colour3,colour4,colour5,nbdisk,return2,return3,mode;
  33.  extern int lline,linemax,choice,modif,pfdiv,pfserv,returning,recording;
  34.  extern unsigned int ref,nbref,nbrep;
  35.  extern long dep,depdiv;
  36.  extern unsigned long nbbytes;
  37.  extern unsigned char c0,c1,trashcan[],path[],nc1[],trashret[],filedir[];
  38.  extern unsigned char work[],record[],saverep[],divers[];
  39.  extern char *memory;
  40.  extern struct ffblk ffblk;
  41.  extern struct dfree dfree;
  42.  extern struct text_info ti;
  43.  extern struct directory{
  44.                 unsigned char name[9];
  45.                 unsigned char ext[4];
  46.                 unsigned char size[9];
  47.                 unsigned char attribut[2];
  48.                 unsigned char date[9];
  49.                 unsigned char time[6];
  50.                } directory;
  51.  
  52.  /*---------------------------*
  53.   * BACK TO DEFAULT DIRECTORY *
  54.   *---------------------------*/
  55.   void back_to_default_directory()
  56.     {
  57.       /* Get the path stored in the service file */
  58.       i=open_working_file();
  59.       if(i==0)                         return;
  60.       dep+=40;
  61.       lseek(pfserv,dep,0);             read(pfserv,path,64);
  62.       close(pfserv);                   pfserv=0;
  63.       strncpy(nc1,path,2);             nc1[2]=0x00;
  64.       system(nc1);                     chdir(path);
  65.       directory_change();
  66.     }
  67.  /*------------------------*
  68.   * DEFINE WORK DIRECTORY  *
  69.   * files on which we work *
  70.   *------------------------*/
  71.   void define_the_work_directory()
  72.     {
  73.       blank_line_25();             textattr(colour3);
  74.       gotoxy(1,25);                    cputs("Working Dir=");
  75.       strcpy(trashcan,path);
  76.       returning=get_or_change_a_word(13,25,64);
  77.       if(returning>0){
  78.         strcpy(path,trashret);
  79.         /* We save the new path */
  80.         i=open_working_file();
  81.     if(i==0)                       return;
  82.     dep+=40;
  83.     lseek(pfserv,dep,0);           write(pfserv,path,64);
  84.     close(pfserv);                 pfserv=0;
  85.       }
  86.     }
  87.  /*-------------------------*
  88.   * DEFINE SYSTEM DIRECTORY *
  89.   * program & config path   *
  90.   *-------------------------*/
  91.   void define_the_system_directory()
  92.     {
  93.       i=message(" Program"," directory"," Are you sure"," you want to"," change it ? Y/N");
  94.       if(i!=34)                        return;
  95.       blank_line_25();                 textattr(colour3);
  96.       gotoxy(1,25);                    cputs("System Dir =");
  97.       strcpy(trashcan,work);
  98.       returning=get_or_change_a_word(13,25,64);
  99.       if(returning>0){
  100.         strcpy(work,trashret);
  101.         /* Save the new path name */
  102.         i=open_working_file();
  103.     if(i==0)                       return;
  104.     dep+=168;
  105.     lseek(pfserv,dep,0);           write(pfserv,work,64);
  106.     close(pfserv);                 pfserv=0;
  107.       }
  108.     }
  109.  /*----------------------------*
  110.   * DEFINE RECORDING DIRECTORY *
  111.   *----------------------------*/
  112.     void define_recording_directory()
  113.     {
  114.       blank_line_25();             textattr(colour3);
  115.       gotoxy(1,25);                cputs("Record Rep =");
  116.       strcpy(trashcan,record);
  117.       returning=get_or_change_a_word(13,25,64);
  118.       if(returning>0){
  119.         strcpy(record,trashret);
  120.         /* Save the new path name */
  121.         i=open_working_file();
  122.     if(i==0)                       return;
  123.     dep+=104;
  124.         lseek(pfserv,dep,0);           write(pfserv,record,64);
  125.     close(pfserv);                 pfserv=0;
  126.       }
  127.     }
  128.  /*-------------------------------*
  129.   *   RECORDING OF SELECTED FILE  *
  130.   * Sub function of the directory *
  131.   *      manager (CPPFIC1B.C).    *
  132.   *-------------------------------*/
  133.   void recording_of_the_selected_file()
  134.     {
  135.       if(recording==0)                 return;
  136.       /* We reserved *divers to store the Copy DOS Command  */
  137.       /* at the beginning of the recording                  */
  138.       strcpy(divers,"COPY ");
  139.       /* Get the name of the file to be recorded      */
  140.       /* and the directory that has just been created */
  141.       memcpy(&directory,memory,39);      strcpy(trashcan,directory.name);
  142.       /* Cut spaces at the end of the name */
  143.       j=strlen(trashcan);
  144.       for(i=j; i>-1; i--){
  145.         c1=trashcan[i];
  146.         if((c1==0x20)||(c1==0x00))     trashcan[i]=0x00;
  147.     else                           break;
  148.       }
  149.       strcat(divers,trashcan);         strcpy(trashcan,directory.ext);
  150.       /* Cut spaces at the end of the extension */
  151.       j=strlen(trashcan);
  152.       for(i=j; i>-1; i--){
  153.         c1=trashcan[i];
  154.         if((c1==0x20)||(c1==0x00))     trashcan[i]=0x00;
  155.     else                           break;
  156.       }
  157.       if(strlen(trashcan)>0){
  158.         strcat(divers,".");            strcat(divers,trashcan);
  159.       }
  160.       strcat(divers," ");              strcat(divers,saverep);
  161.       nc1[0]=0x00;                     strcat(divers,nc1);
  162.       gotoxy(1,24);                    system(divers);
  163.     }
  164.  /*------------------*
  165.   * GET CURRENT MODE *
  166.   *------------------*/
  167.  void get_current_mode()
  168.    {
  169.      gettextinfo(&ti);                 mode=ti.currmode;
  170.      if(ti.currmode==2)                strcpy(trashcan,"N & B  80 col");
  171.      if(ti.currmode==3)                strcpy(trashcan,"Col.   80 col");
  172.      if(ti.currmode==7)                strcpy(trashcan,"Monoch 80 col");
  173.      if(ti.currmode==64)               strcpy(trashcan,"EGA/VGA 43/50");
  174.    }
  175.  /*----------------------------*
  176.   * DISPLAY FREE SPACE ON DISK *
  177.   *----------------------------*/
  178.   void display_free_space_on_disk()
  179.     {
  180.       j=getdisk();                     getdfree((j+1), &dfree);
  181.       if(dfree.df_sclus==0xffff){
  182.         warning(" Error during"," the call of"," Free Space"," on Drive.Click or"," Press any Key");
  183.     return;
  184.       }
  185.       dep=(long) dfree.df_avail * (long) dfree.df_bsec * (long) dfree.df_sclus;
  186.       ltoa(dep,trashcan,10);           put_separators();
  187.       right_justify_the_text(trashcan,12);  strcat(trashret," bytes");
  188.       strcpy(trashcan,"on the drive:  ");    j=getdisk();
  189.       if(j==0)                         strcat(trashcan,"A:");
  190.       if(j==1)                         strcat(trashcan,"B:");
  191.       if(j==2)                         strcat(trashcan,"C:");
  192.       if(j==3)                         strcat(trashcan,"D:");
  193.       if(j==4)                         strcat(trashcan,"E:");
  194.       if(j>4)                          strcat(trashcan,"testé");
  195.       message(" Free Space",trashcan,trashret," Press any Key"," or click");
  196.     }
  197. /*-----------------------*/
  198. /* End of the Module *//*---------------------------*/
  199.  
  200.